import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:largefriends/pages/lf_login/lf_login_logic.dart';
import 'package:largefriends/pages/lf_register/lf_register_logic.dart';
import 'package:largefriends/res/lf_color.dart';
import 'package:largefriends/res/lf_double_ext.dart';
import 'package:largefriends/res/lf_widget_ext.dart';
import 'package:largefriends/res/strings/lf_strings.dart';

import '../../config/lf_config.dart';
import '../../res/lf_fonts.dart';
import '../../res/lf_text_style.dart';
import '../../widgets/lf_button.dart';
import 'lf_splash_logic.dart';

class LfSplashPage extends StatefulWidget {
  const LfSplashPage({Key? key}) : super(key: key);

  @override
  _LfSplashPageState createState() {
    return _LfSplashPageState();
  }
}

class _LfSplashPageState extends State<LfSplashPage> {
  final logic = Get.put(LfSplashLogic());
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return WillPopScope(
        child: Scaffold(
          appBar: null,
          extendBodyBehindAppBar: true,
          body: Stack(
            children: [
              Positioned.fill(
                  child: Container(
                decoration: BoxDecoration(
                    gradient: RadialGradient(
                        colors: [
                      colorBF00FF.withAlpha(6),
                      color000000.withAlpha(150),
                          color000000.withAlpha(100)
                    ],
                        tileMode: TileMode.clamp,
                        center: const Alignment(0.9, -1),
                        radius: 2)),
              )),
              Positioned.fill(
                  child: Container(
                decoration: BoxDecoration(
                    gradient: RadialGradient(
                        colors: [
                      colorFF007F.withAlpha(6),
                          color000000.withAlpha(100),
                          color000000.withAlpha(60)
                    ],
                        tileMode: TileMode.clamp,
                        center: const Alignment(1.2, 1.5),
                        radius: 4)),
              )),
              Positioned.fill(
                  child: BackdropFilter(
                filter: ImageFilter.blur(sigmaX: 30, sigmaY: 20),
                child: SizedBox(
                  height: ScreenUtil().screenHeight,
                  width: ScreenUtil().screenWidth,
                ),
              )),
              Column(
                children: [
                  emptyExpand,
                  ShaderMask(
                      shaderCallback: (Rect bounds) {
                        return LinearGradient(
                          begin: const Alignment(-0.5, -0.9),
                          end: const Alignment(0.5, 0.9),
                          colors: [
                            colorFF007F,
                            colorFF007F,
                            colorBF00FF,
                            colorBF00FF
                          ],
                        ).createShader(Offset.zero & bounds.size);
                      },
                      blendMode: BlendMode.srcATop,
                      child: Text(
                        appName,
                        style:
                            lfTextStyle(sp: 48.sp, fontFamily: fontYoungSerif),
                      )),
                  emptyExpand,
                  Obx(() => Visibility(
                        visible: logic.showLogin.isTrue,
                        child: LfButton(
                          enabled: true,
                          text: strCreateNewAccount.tr,
                          onPress: () {
                            toRegisterPage();
                          },
                        ),
                      )),
                  20.h.sbh,
                  ScreenUtil().screenWidth.sbw,
                  Obx(() => Visibility(
                        visible: logic.showLogin.isTrue,
                        child: InkWell(
                          child: Container(
                            margin: EdgeInsets.symmetric(
                              horizontal: 20.w,
                            ),
                            width: double.infinity,
                            padding: EdgeInsets.symmetric(vertical: 15.h),
                            alignment: Alignment.center,
                            decoration: BoxDecoration(
                                color: Colors.white,
                                border:
                                    Border.all(color: Colors.white, width: 2.r),
                                borderRadius:
                                    BorderRadius.all(Radius.circular(40.h))),
                            child: Text(
                              strSignUpWithEmail.tr,
                              style: lfTextStyle(
                                sp: 16.sp,
                                color: color210215,
                                fontFamily: fontBold,
                              ),
                            ),
                          ),
                          onTap: () {
                            toLoginPage();
                          },
                        ),
                      )),
                  80.h.sbh,
                ],
              )
            ],
          ),
        ),
        onWillPop: () async {
          return false;
        });
  }
}
